#ifndef __CUserPet_h__
#define __CUserPet_h__

#include "CTArray.h"
#include "../item/CDropItem.h"
#include "CPetConfig.h"
#include "../cmdfront/cmdpet.h"

#define DEFAULT_PET_NAME  "小乐扣"

class CPetMgr;
class MsgPetBriefInfo;

class CUserPet
{
    friend class CPetMgr;
public:
	CUserPet() : _uiGID(0)
    {
        m_bCanExplore = false;
	}

	virtual ~CUserPet() 
    {
	}

    void Clean();

    void SetUserGid(unsigned int uiGid);

    unsigned int GetUserGid() const;

    /*
    CAREER_1 = 1,       //魔剑士 sword
    CAREER_2 = 2,       //魔法师 mage
    CAREER_3 = 3,       //魔猎手 bow
    CAREER_4 = 4,       //魔斗士 awl
    魔法师获得魔攻宠物猫头鹰，魔剑士和魔猎手获得物攻宠物仓鼠
    */
    int Init(unsigned char _ucCareer);

    //取得宠物等阶
    int GetPetLevel();

    //取得宠物星级
    int GetPetStar();

    int ShuffleExploreEventList();

    int InitData(CPetData& stUserData);

    int GetData(CPetData& stUserPetData);

    CPetData& GetDataRef();

    bool HasFruitNotRecv();

    //更新批量信息
    void SetPetInfoBatch( int & iLevel, int & iStar, int & iCurExper, FruitAwardArray & aAwardFruits );

    //同一天必须相同,比较年，月，日即可
    int ConsumeDayFlag();

    int GetRandomRange(int iMin, int iMax);

    int GetPetLevelStarFruit(int & iLevel, int& iStar, int& iFruitNum);

    void PetExplore(int iCDTimes);

    //吃一个增益果实
    void PetTrainFruit();
    int GetPetHasEatFruit()
    {
        return m_petData._iPetFruit;
    }

    //获得宠物经验
    void TriggerIncrExper(int iExperValue);

    //请求宠物升阶
    int PetReqUpdateLevel();

    //领取果实
    int PetRecvFruit();

    int PetSendFruit2Storage();

    int CheckCDTime();

    int PetClearCDTime();

    //大暴击直接提升星级
    void TriggerBigCrit();

    int GetExploreAwardItems(CPetExploreConfigData& stConfigData, CDropItem& stDropItem);
    int GetExploreAwardItemsWithLevel(short iLevel, CPetExploreConfigData& stConfigData, CDropItem& stDropItem);

    int PetRename(CTSizeString<PETNAME_LEN>& szPetName);

    //查询剩余探险次数
    int GetPetExploreCounts();

    int GetPetExper();

    void TriggerCritNumDesc();

    int GetCurPetExper();

    int PetIsActive();

    //根据剩余次数取出探险事件id
    int GetPetExploreId(int iRemainCounts);

    /*
     * Return: 0:sucess
     *         1:宠物等阶升级了，petMgr收到此信息需要做全服广播
     *         other: error
     * */
    int CheckPetUpdate();

    //查询剩余每天前三次金币培养100%暴击次数
    int GetPetCritCounts();
    //查询剩余每天前三次金币培养100%暴击次数,但不做立即更新
    int GetPetCritCountsNotUpdate();

    int PetChangeStyle(int iPetNewStyle);

    int PetEnableNewStyle(int iPetNewStyle);

    int UpdatePetStatus();

    int UpdatePetInfo2Front();

    int GetPetAttrs(
                        CPetLevelConfigData& stLevelConfigData, 
                        CPetStarConfigData& stStarConfigData, 
                        CPlayerAttr& astPetAttrs);

    int GetPetFrontID();

    void GetPetBriefInfo(MsgPetBriefInfo& stMsgPetBriefInfo);

    const char* GetPetName()
    {
        return m_petData._sPetName();
    }

    int GetMaxStyleID()
    {
        return m_petData._iPetMaxCanUseStyle;
    }

public:
    bool                                                        m_bCanExplore;              //是否可以探险

private:
    unsigned int                                                _uiGID;                     
    bool                                                        m_bPetStatusChange;        //record the pet status change 

    CPetData                                                    m_petData;      //宠物的相关信息
};


#endif // __CUserPet_h__

